#include <builder_pattern.h>

string Wrapper::pack()
{
    return "Wrapper";
}

string Bottle::pack()
{
    return "Bottle";
}

Packing * Burger::packing()
{
    return new Wrapper();
}

Packing * ColdDrink::packing()
{
    return new Bottle();
}

float VegBurger::price()
{
    return 25.0f;
}

string VegBurger::name()
{
    return "Veg Burger";
}

float ChickenBurger::price()
{
    return 50.5f;
}

string ChickenBurger::name()
{
    return "Chicken Burger";
}

float Coke::price()
{
    return 30.0f;
}

string Coke::name()
{
    return "Coke";
}

float Pepsi::price()
{
    return 35.0f;
}

string Pepsi::name()
{
    return "Pepsi";
}

void Meal::addItem(Item * item)
{
    items->push_back(item);
}

float Meal::getCost()
{
    float cost = 0.0f;
    list<Item*>::iterator iter = items->begin();
    for(; iter != items->end(); iter++)
    {
        cost += (**iter).price();
    }
    return cost;
}

void Meal::showItems()
{
    list<Item*>::iterator iter = items->begin();
    for(; iter != items->end(); iter++)
    {
        cout << "Item : " << (**iter).name();
        cout << ", Packing : " << (**iter).packing()->pack();
        cout << ", Price : " << (**iter).price() << endl;
    }
}

Meal* MealBuilder::prepareVegMeal()
{
    Meal* meal = new Meal();
    meal->addItem(new VegBurger);
    meal->addItem(new Coke());
    return meal;
}

Meal* MealBuilder::prepareNonVegMeal()
{
    Meal* meal = new Meal();
    meal->addItem(new ChickenBurger());
    meal->addItem(new Pepsi());
    return meal;
}

/*
    MealBuilder* mealBuilder = new MealBuilder();
    Meal* vegMeal = mealBuilder->prepareVegMeal();
    cout << "Veg Meal" << endl;
    vegMeal->showItems();
    cout << "Total Cost : " << vegMeal->getCost() << endl;

    Meal* nonVegMeal = mealBuilder->prepareNonVegMeal();
    cout << "\n\nNone-Veg Meal" << endl;
    nonVegMeal->showItems();
    cout << "Total Cost : " << nonVegMeal->getCost() << endl;
    */
